import axios from 'axios'
const baseurl = _ctxPath + '/rest/cap4/tree'

// axios.defaults.timeout = 6000;
axios.interceptors.response.use((res) => {
  let {status, data} = res
  let {code, message} = data
  if (status != 200 && status != 304 && status != "0") {
    return
  }
  if (code == "0" && data.data) {
    return data.data
  } else {
    return data
  }
})

export const getTreeData = params => axios.post(baseurl + '/allTree',params)

export const addTree = (data) => axios({
    url: baseurl + '/addTree',
    method: 'POST',
    data: data
})

export const udpateTree = data => axios.put(baseurl + '/updateTree',data)
// 360dd9a8-440d-48ae-a78c-aff50cd9a35e

export const addTreeForm = data => axios.post(_ctxPath + '/rest/cap4/tree_form/addTreeForm',data)

// 传应用Id，-4867901369476888163
export const getAllForm = data => axios.post(_ctxPath + '/rest/cap4/tree_form/allForms', data)

export const getAllTreeForm = data => axios.post(_ctxPath + '/rest/cap4/tree_form/allTreeForm',data)

export const getFormField = formId => axios.get(_ctxPath + '/rest/cap4/tree_form/form/' + formId)

export const getEnumData = () => axios.get(_ctxPath + '/rest/cap4/tree_form/enumData')

export const getCalculateObject = () => axios.get(_ctxPath + '/rest/cap4/tree_form/calculateObject')